const OPTION = {
  animation:false,
  color: [
    '#05e5d2',
    '#19fc6c',
    '#e3d902',
    '#03a7e8',
    "#fc531d",
    "#ad0af1",
    "#218ffc",
    "#23d6de",
    "#1cd4a3",
    "#18d918",
  ],
  tooltip: {
    trigger: 'axis',
    position: function (pt) {
      return [pt[0], '10%'];
    },
  },
  grid: {
    left: '30',
    right: '10',
    bottom: '10',
    top: '80',
    containLabel: true
  },
  legend: {
    textStyle: {
      fontSize: 14,//字体大小
      color: '#3AECFF'//字体颜色
    }
  },
  xAxis: {
    type: 'time',
    name: '时间（s）',
    boundaryGap: false,
    splitNumber: 5,
    axisLabel: {
      color: '#3AECFF'
    },
  },
  yAxis: {
    type: 'value',
    name: '震动加速度(mg)',
    nameTextStyle: {
      fontSize: 12,//字体大小
      color: '#3AECFF',//字体颜色
      left: -50
    },
    // boundaryGap: [0, '50%'],
    axisLabel: {
      formatter: '{value}',
      color: '#3AECFF'
    },
    splitLine: {
      show: true,
      lineStyle: {
        color: 'rgba(58,236,255,0.82)',
        width: 1,
        type: 'solid'
      }
    },
  },
  series: []

};

export function mergeOptions(source: any, target?: any) {
  if (!target) {
    target = {}
  }
  for (let key in source) {
    let element = source[key]
    if (element && typeof element === "object") {
      if (element instanceof Date) {   // 日期格式
        target[key] = new Date(element)
      } else if (element instanceof Array) {   // 日期格式
        target[key] = element
      } else {
        target[key] = mergeOptions(element, target[key])
      }
    } else {
      if (target[key]===undefined) {
        target[key] = element
      }
    }
  }
  return target
}

export default function getThemeConfig() {
  return mergeOptions(OPTION)
}
